package cn.tac.test.spring.bean.xml.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * Created by tac on 24/10/2017.
 */
public class ShowLifeCycleBean implements InitializingBean, BeanNameAware, BeanFactoryAware, ApplicationContextAware {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    private BeanFactory beanFactory;
    private ApplicationContext applicationContext;

    public void afterPropertiesSet() throws Exception {
        logger.info("all properties has been set");
    }

    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
        logger.info("bean factory has been set");
    }

    public void setBeanName(String name) {
        logger.info("bean name:" + name);
    }

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
        logger.info("application context has been set");
    }
}
